package com.sghd.football.utils;

import com.sghd.common.console.Console;
import com.sghd.football.module.game.service.GameService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;

public class ConsoleDefin extends Console {
    public static final Logger logger = LoggerFactory.getLogger(ConsoleDefin.class);
    private ApplicationContext applicationContext;

    public ConsoleDefin(AbstractApplicationContext applicationContext) {
        super(applicationContext);
        this.applicationContext = applicationContext;
    }

    @Override
    public void stop() {
        GameService gameService = applicationContext.getBean(GameService.class);
        gameService.submit(new Runnable() {
            @Override
            public void run() {
                gameService.destory();
            }
        });
        super.stop();
    }

}
